package jp.co.kayo.ykmjuku.android.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class Fragment2 extends Fragment implements OnClickListener {
    int mCount = 0;
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment2, container, false);
        
        Button btn = (Button)root.findViewById(R.id.button1);
        btn.setOnClickListener(this);
        return root;
    }
    
    @Override
    public void onClick(View v) {
        FragmentTransaction tr = getFragmentManager().beginTransaction();
        Fragment3 f = new Fragment3("from fragment2 "+ (mCount++));
        tr.replace(R.id.frameLayout2, f);
        tr.addToBackStack("fragment2");
        tr.commit();
    }
}
